﻿using JESAI.HttpRequestMonitor.Core.Abstracts;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace JESAI.HttpRequestMonitor.Dashboard.Services.Language
{
    public class LanguageService
    {
        private readonly IRequestMonitorStorage _storage;
        private readonly ChineseLanguage _chineseLanguage;
        private readonly EnglishLanguage _englishLanguage;
        public LanguageService(IRequestMonitorStorage storage, ChineseLanguage chineseLanguage, EnglishLanguage englishLanguage)
        {
            _storage = storage;
            _chineseLanguage = chineseLanguage;
            _englishLanguage = englishLanguage;
        }

        public async Task<ILanguage> GetLanguage()
        {
            var language = await _storage.GetSysConfig(SysConst.Language);

            if (language == "English")
            {
                return _englishLanguage as ILanguage;
            }

            if (language == "Chinese")
            {
                return _chineseLanguage as ILanguage;
            }

            return null;
        }
    }
}
